import { getDictData } from '@/api/manage'
import Vue from 'vue'
const dict = {
  state: {
    dictData: {}
  },
  mutations: {
    // 设置值的改变方法
    setDict (state, list) {
      state.dictData = list
    }
  },
  actions: {
    // 登录
    InitDict ({ commit }) {
      return new Promise((resolve, reject) => {
        getDictData().then(response => {
          const result = response.data
          Vue.ls.set('DICTDATA', result)
          Vue.prototype.$dictData = result
          commit('setDict', result)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default dict
